

package com.maoshi.shop.distribution.comment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maoshi.shop.common.config.Constant;
import com.maoshi.shop.distribution.comment.dao.DistributionWithdrawCashSetMapper;
import com.maoshi.shop.distribution.comment.model.DistributionWithdrawCashSet;
import com.maoshi.shop.distribution.comment.service.DistributionWithdrawCashSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * 提现设置
 *
 * @author xwc
 * @date 2019-04-13 15:45:12
 */
@Service
public class DistributionWithdrawCashSetServiceImpl extends ServiceImpl<DistributionWithdrawCashSetMapper, DistributionWithdrawCashSet> implements DistributionWithdrawCashSetService {

    @Autowired
    private DistributionWithdrawCashSetMapper distributionWithdrawCashSetMapper;

    @Override
    @Cacheable(cacheNames = "DistributionWithdrawCashSet", key = "'0'")
    public DistributionWithdrawCashSet getByShopId() {
        DistributionWithdrawCashSet distributionWithdrawCashSet = distributionWithdrawCashSetMapper.selectOne(new LambdaQueryWrapper<DistributionWithdrawCashSet>()
                .eq(DistributionWithdrawCashSet::getShopId, Constant.PLATFORM_SHOP_ID)
        );
//        if(distributionWithdrawCashSet == null){
//            return  createInitialDistributionWithdrawCash(shopId);
//        }
        return distributionWithdrawCashSet;
    }

//    @Override
//    public DistributionWithdrawCashSet createInitialDistributionWithdrawCash(Long shopId) {
//        DistributionWithdrawCashSet distributionWithdrawCashSet = new DistributionWithdrawCashSet();
//        distributionWithdrawCashSet.setShopId(shopId);
////        distributionWithdrawCashSet.setSettlementTime(0);
////        distributionWithdrawCashSet.setSettlementMode(0);
////        distributionWithdrawCashSet.setSettlementAutoSet(0);
//        distributionWithdrawCashSet.setFrequency(-1);
//        distributionWithdrawCashSet.setAmountMin(0.0);
//        distributionWithdrawCashSet.setAmountMax(1000.0);
////        distributionWithdrawCashSet.setModeOfPayment(0);
//        distributionWithdrawCashSetMapper.insert(distributionWithdrawCashSet);
//        return distributionWithdrawCashSet;
//    }

    @Override
    @CacheEvict(cacheNames = "DistributionWithdrawCashSet", key = "'0'")
    public void removeCacheByShopId(Long shopId) {

    }


}
